<?php

namespace Modules\ShopAdmin\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class ShopsTableSeederTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
/*******************************用户数据************************************/
		DB::table('shop_users')->insert([
			'xcx_open_id'=>'ovVCR4gIH9Rp2QNLtjxrU0TOwUm4',
			'phone'=>'18092444782',
			'password'=>bcrypt(config('shopapi.user_password')),
			'nick_name'=>'A~LvaCMS 作者',
			'avatar_url'=>'https://wx.qlogo.cn/mmopen/vi_32/43DvTL3ghhh1w5yOiajWgwKGyTQicUtQC4Wu7FeIoXfqFYAKPicxOj6BqCOAKmMPBCremNrZFcBEFchymKtlxdnSw/132',
			'status'=>1,
			'gender'=>1,
			'created_at'=>date('Y-m-d H:i:s')
		]);
/*******************************banner数据************************************/
		$image_id = DB::table('auth_images')->insertGetId([
			'url'=>'/upload/images/shop/banner/1.png',
			'created_at'=>date('Y-m-d H:i:s')
		]);
		DB::table('shop_pictures')->insert([
			'image_id'=>$image_id,
			'type'=>1,
			'status'=>1,
			'sort'=>1,
			'the_jump'=>0,
			'created_at'=>date('Y-m-d H:i:s')
		]);
		$image_id = DB::table('auth_images')->insertGetId([
			'url'=>'/upload/images/shop/banner/2.png',
			'created_at'=>date('Y-m-d H:i:s')
		]);
		DB::table('shop_pictures')->insert([
			'image_id'=>$image_id,
			'type'=>1,
			'status'=>1,
			'sort'=>1,
			'the_jump'=>0,
			'created_at'=>date('Y-m-d H:i:s')
		]);
		$image_id = DB::table('auth_images')->insertGetId([
			'url'=>'/upload/images/shop/banner/3.png',
			'created_at'=>date('Y-m-d H:i:s')
		]);
		DB::table('shop_pictures')->insert([
			'image_id'=>$image_id,
			'type'=>1,
			'status'=>1,
			'sort'=>1,
			'the_jump'=>0,
			'created_at'=>date('Y-m-d H:i:s')
		]);
/*******************************商品数据************************************/
		
		$product_type_name_arr = [
			"推荐分类",
			"进口超市",
			"国际名牌", 
			"奢侈品", 
			"海囤全球", 
			"男装", 
			"女装",
			"男鞋", 
			"女鞋", 
			"钟表珠宝", 
			"手机数码", 
			"电脑办公", 
			"家用电器", 
			"玩具乐器",
			"运动户外",
			"宠物生活",
			"特产馆"
		];
		
		for($i=0;$i<17;$i++){
			$image_id = DB::table('auth_images')->insertGetId([
				'url'=>'/upload/images/shop/banner/'.(($i%3)+1).'.png',
				'created_at'=>date('Y-m-d H:i:s')
			]);
			$product_type_id1 = DB::table('shop_product_types')->insertGetId([
				'title'=>$product_type_name_arr[$i],
				'image_id'=>$image_id,
				'pid'=>0,
				'level'=>1,
				'status'=>1,
				'sort'=>1,
				'created_at'=>date('Y-m-d H:i:s')
			]);
			for($j=0;$j<10;$j++){
				$image_id = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/category/'.(($j%10)+1).'.jpg',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$product_type_id2 = DB::table('shop_product_types')->insertGetId([
					'title'=>'分类'.$i.$j,
					'image_id'=>$image_id,
					'pid'=>$product_type_id1,
					'level'=>2,
					'status'=>1,
					'sort'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_key_id1 = DB::table('shop_product_attrbute_keys')->insertGetId([
					'product_type_id'=>$product_type_id2,
					'name'=>'颜色',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id1 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id1,
					'value'=>'五角星钻耳线',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id2 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id1,
					'value'=>'米子珍珠耳线',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id3 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id1,
					'value'=>'花朵镶钻耳线',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id4 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id1,
					'value'=>'扇子珍珠流苏耳线',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_key_id2 = DB::table('shop_product_attrbute_keys')->insertGetId([
					'product_type_id'=>$product_type_id2,
					'name'=>'尺寸',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id5 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id2,
					'value'=>'5cm',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id6 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id2,
					'value'=>'8cm',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id7 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id2,
					'value'=>'12cm',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id8 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id2,
					'value'=>'16cm',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$attrbute_value_id9 = DB::table('shop_product_attrbute_values')->insertGetId([
					'attrbute_key_id'=>$attrbute_key_id2,
					'value'=>'18cm',
					'sort'=>1,
					'status'=>1,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/product/'.(($j%6)+1).'.jpg',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id1 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/1.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id2 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/2.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id3 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/3.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id4 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/4.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id5 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/5.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id6 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/6.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id7 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/7.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id8 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/8.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$product_id = DB::table('shop_products')->insertGetId([
					'product_type_id'=>$product_type_id2,
					'name'=>'谈判官明星同款耳坠'.$i.$j,
					'describe'=>'谈判官明星同款耳坠韩国气质简约显脸瘦的耳环女百搭个性长款耳钉 个性水滴耳环【A2】'.$i.$j,
					'image_id'=>$image_id,
					'images'=>$image_id1.'|'.$image_id2.'|'.$image_id3.'|'.$image_id4.'|'.$image_id5.'|'.$image_id6.'|'.$image_id7.'|'.$image_id8,
					'attrbute_list'=>'[{"id":20,"name":"尺寸","sub":[{"id":86,"name":"5cm"},{"id":87,"name":"8cm"},{"id":88,"name":"12cm"},{"id":89,"name":"16cm"},{"id":90,"name":"18cm"}]},{"id":19,"name":"颜色","sub":[{"id":82,"name":"五角星钻耳线"},{"id":83,"name":"米子珍珠耳线"},{"id":84,"name":"花朵镶钻耳线"},{"id":85,"name":"扇子珍珠流苏耳线"}]}]',
					'content'=>'<p>商品详情</p>',
					'status'=>1,
					'specs_status'=>1,
					'recommend_status'=>0,
					'best_status'=>0,
					'sort'=>1,
					'sales'=>$i+$j,
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+5,
					'postage'=>0,
					'is_delete'=>0,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":86,"name":"5cm"},{"id":82,"name":"五角星钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+5,
					'cost_money'=>$i+$j+2,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'86|82',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":86,"name":"5cm"},{"id":83,"name":"米子珍珠耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+6,
					'cost_money'=>$i+$j+3,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'86|83',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":86,"name":"5cm"},{"id":84,"name":"花朵镶钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+7,
					'cost_money'=>$i+$j+4,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'86|84',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":86,"name":"5cm"},{"id":85,"name":"扇子珍珠流苏耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+8,
					'cost_money'=>$i+$j+5,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'86|85',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":87,"name":"8cm"},{"id":82,"name":"五角星钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+9,
					'cost_money'=>$i+$j+6,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'87|82',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":87,"name":"8cm"},{"id":83,"name":"米子珍珠耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+10,
					'cost_money'=>$i+$j+7,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'87|83',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":87,"name":"8cm"},{"id":84,"name":"花朵镶钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+11,
					'cost_money'=>$i+$j+8,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'87|84',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":87,"name":"8cm"},{"id":85,"name":"扇子珍珠流苏耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+12,
					'cost_money'=>$i+$j+9,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'87|85',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":88,"name":"12cm"},{"id":82,"name":"五角星钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+13,
					'cost_money'=>$i+$j+10,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'88|82',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":88,"name":"12cm"},{"id":83,"name":"米子珍珠耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+14,
					'cost_money'=>$i+$j+11,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'88|83',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":88,"name":"12cm"},{"id":84,"name":"花朵镶钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+15,
					'cost_money'=>$i+$j+12,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'88|84',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":88,"name":"12cm"},{"id":85,"name":"扇子珍珠流苏耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+16,
					'cost_money'=>$i+$j+13,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'88|85',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":89,"name":"16cm"},{"id":82,"name":"五角星钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+17,
					'cost_money'=>$i+$j+14,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'89|82',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":89,"name":"16cm"},{"id":83,"name":"米子珍珠耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+18,
					'cost_money'=>$i+$j+15,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'89|83',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":89,"name":"16cm"},{"id":84,"name":"花朵镶钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+19,
					'cost_money'=>$i+$j+16,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'89|84',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":89,"name":"16cm"},{"id":85,"name":"扇子珍珠流苏耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+20,
					'cost_money'=>$i+$j+17,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'89|85',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":90,"name":"18cm"},{"id":82,"name":"五角星钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+21,
					'cost_money'=>$i+$j+18,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'90|82',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":90,"name":"18cm"},{"id":83,"name":"米子珍珠耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+22,
					'cost_money'=>$i+$j+19,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'90|83',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":90,"name":"18cm"},{"id":84,"name":"花朵镶钻耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+23,
					'cost_money'=>$i+$j+20,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'90|84',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'specs'=>'[{"id":90,"name":"18cm"},{"id":85,"name":"扇子珍珠流苏耳线"}]',
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+24,
					'cost_money'=>$i+$j+21,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'sku'=>'90|85',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				
				
				$image_id = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/product/'.(($j%6)+1).'.jpg',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id1 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/1.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id2 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/2.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id3 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/3.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id4 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/4.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id5 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/5.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id6 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/6.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id7 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/7.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$image_id8 = DB::table('auth_images')->insertGetId([
					'url'=>'/upload/images/shop/product/8.png',
					'created_at'=>date('Y-m-d H:i:s')
				]);
				$product_id = DB::table('shop_products')->insertGetId([
					'product_type_id'=>$product_type_id2,
					'name'=>'谈判官明星同款耳坠'.$i.$j,
					'describe'=>'谈判官明星同款耳坠韩国气质简约显脸瘦的耳环女百搭个性长款耳钉 个性水滴耳环【A2】'.$i.$j,
					'image_id'=>$image_id,
					'images'=>$image_id1.'|'.$image_id2.'|'.$image_id3.'|'.$image_id4.'|'.$image_id5.'|'.$image_id6.'|'.$image_id7.'|'.$image_id8,
					'content'=>'<p>商品详情</p>',
					'status'=>1,
					'specs_status'=>0,
					'recommend_status'=>0,
					'best_status'=>0,
					'sort'=>1,
					'sales'=>$i+$j,
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+5,
					'postage'=>0,
					'is_delete'=>0,
					'created_at'=>date('Y-m-d H:i:s')
				]);
				DB::table('shop_product_specs')->insert([
					'product_id'=>$product_id,
					'money'=>'0.01',
					'bazaar_money'=>$i+$j+5,
					'cost_money'=>$i+$j+2,
					'postage'=>0,
					'stock'=>$i+$j,
					'sales'=>$i+$j,
					'created_at'=>date('Y-m-d H:i:s')
				]);
			}
		}
    }
}